<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	$(function(){
		$("#name").blur(function(){
			if ($(this).val()!="") {
				$.post("CheckUserName",{
					username:$(this).val()
				},callback)
			}else{
				$("#cname").html("用户名不能为空");
				$(":submit").attr("disabled",true);
			}			
		})
		$("#userlogin").submit(function(){
			var b = true;
			if($("#name").val()==""){
				$("#cname").html("用户名不能为空");
				b= false;
			}
			if($("#pwd").val()==""){
				$("#cpwd").html("密码不能为空");
				b= false;
			}
			return b;
		})
	})
	function callback(data){
		if (data=="true") {
			$("#cname").html("用户名已存在");
			$(":submit").attr("disabled",true);
		}else{
			$("#cname").html("用户名可用");
			$(":submit").attr("disabled",false);
		}
	}
	
</script>
</head>
<body>
	用户注册!<a href="home.jsp">返回登陆页面</a>
	<form action="UserRegister" method="post" id="userlogin">
		请输入账号:<input type="text" name="username" id="name" /><span id="cname"></span><br/>
		请输入密码:<input type="password" name="userpwd" id="pwd"  /><span id="cpwd"></span><br/>
		<input type="submit" value="注册" />
		<input type="reset" value="重置" />	
	</form>
</body>
</html>